let httptool = require("../../utils/zry.httptool.js");
var md5 = require('../../utils/md5.js');
var base64 = require('../../utils/base64.js');  
let app = getApp(); 
Page({
  data: {
    customer: {},
    Tel:'',
    msgprop:'',//消息提示 
  },
  onLoad: function (options) {
    var that = this
    //调用应用实例的方法获取全局数据
    let customer = {};
    customer.Sex = app.getStorage('sex');
    customer.CustomerName = app.getStorage('customerName');
    customer.HeadImg = app.getStorage('headImg');
    customer.OpenId = options.openId;
    customer.UnionId = options.unionId;
    this.setData({ customer: customer});
  },
  telChanage:function(e){
    this.data.customer.Tel = e.detail.value;
    this.setData({ customer: this.data.customer});
    console.log('电话是'+this.data.customer.Tel);
  },
  pwdCheck:function(e){
    this.data.customer.Pwd=e.detail.value;
    this.setData({ customer: this.data.customer});
    console.log('密码是'+this.data.customer.Pwd);
  },
  clearTel:function(e){//清除输入的手机号
    this.data.customer.Tel = '';
    this.setData({customer: this.data.customer});
  },
  clearPwd:function(e){//清除输入的密码
    this.data.customer.Pwd = '';
    this.setData({customer: this.data.customer});
  },
  //注册地址跳转
  registerTap: function() {
    wx.navigateTo({
      url: '/pages/register/register'
    })
  },
  resetTap:function() {
    wx.navigateTo({
      url: '/pages/restpassword/resetpassword'
    })
  },
  loginBtns:function(){
    let that = this;
    // if (that.data.Tel == "") {
    //     app.showNotify(that, "请输入手机号！");
    //     return false;
    // }
    // if (!app.validate(that.data.customer.Tel, 'phone')) {
    //     app.showNotify(that, "手机号不正确");
    //     return false;
    // }
    // if (that.data.customer.Pwd == "") {
    //     app.showNotify(that, "密码不能为空！");
    //     return false;
    // }
    // if( that.data.customer.Pwd != ""){
    //     if(that.data.customer.Pwd.length < 8 ){
    //       app.showNotify(that,"密码不得小于8位！" );
    //       return false;
    //     }else if (!app.validate(that.data.customer.Pwd, 'password')) {
    //       app.showNotify(that, "密码不规范" );
    //       return false;
    //   }
    // }
    let customer = that.data.customer;
    customer.Pwd = base64.encoder(md5.hexMD5(customer.Pwd));
    customer.ClientId = "62ccad6d-9611-41c5-96f6-08ec0ada0f68";
    customer.ClientSecret = "5678";
    customer.Url="http://111.230.116.74/";
    httptool.ajaxBasePost("api/Customer/Login", customer, function (res) {
      if (res.suc) {
        let data = res.data; 
        wx.redirectTo({
          url: '/pages/index/index',
        });
      }else{
        app.showNotify(that, res.msg);
      }
    });
  },
    serviceBtn:function(e){//服务政策
    wx.navigateTo({
      url: '/pages/service/serviceprofile',
    })
  },
  privateProfile:function(e){//隐私政策
    wx.navigateTo({
      url: '/pages/private/privateprofile',
    })
  },
  verifyCheck:function(that){
    
  }

})
